package cn.maidouya.hrm.client;

import cn.maidouya.hrm.doc.CourseDoc;
import cn.maidouya.hrm.query.CourseDocQuery;
import cn.maidouya.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CourseDocFeignFallbackFactory implements FallbackFactory<ICourDocFeignClient>{

    @Override
    public ICourDocFeignClient create(Throwable throwable) {
        return new ICourDocFeignClient() {
            @Override
            public AjaxResult onLineCourse(List<CourseDoc> courseDoc) {
                return AjaxResult.me().setSuccess(false).setResultObj("课程发布失败！");
            }

            @Override
            public AjaxResult offLineCourse(List<Long> ids) {
                return AjaxResult.me().setSuccess(false).setResultObj("课程下线失败！");
            }

            @Override
            public AjaxResult queryCourses(CourseDocQuery courseDocQuery) {
                return AjaxResult.me().setSuccess(false).setResultObj("搜索失败，稍后再试！");
            }
        };
    }
}
